package org.taohuawu.feign.fallback;

import org.springframework.stereotype.Component;
import org.taohuawu.feign.UserFeignService;
import org.taohuawu.pojo.User;
import org.taohuawu.web.util.JsonResult;

@Component
public class UserFeignServiceFallback implements UserFeignService {
    @Override
    public JsonResult<User> getUser(Integer userId) {
        if (Math.random() < 0.4) {
            return JsonResult.ok(new User(userId, "缓存name" + userId, "缓存password" + userId));
        }
        return JsonResult.err("无法获取订单的用户信息");
    }

    @Override
    public JsonResult addScore(Integer userId, Integer score) {
        return JsonResult.err("增加积分失败");
    }
}
